package org.linlinjava.litemall.admin.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.linlinjava.litemall.admin.beans.annotation.LogAnno;
import org.linlinjava.litemall.admin.beans.annotation.LoginAdminId;
import org.linlinjava.litemall.admin.dto.AdminPosAdDTO;
import org.linlinjava.litemall.admin.service.AdminPosAdService;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@Api(tags = "POS外屏广告API")
@RestController
@RequestMapping("/admin/posad")
@RequiredArgsConstructor
public class AdminPosAdController extends ResponseUtil {

    private final AdminPosAdService adminPosAdService;
    @ApiOperation("POS广告上传")
    @LogAnno
    @PostMapping(value = {"/posAdUploader"})
        public Response PosAdUploader(@RequestBody AdminPosAdDTO adminPosAdDTO, @LoginAdminId Integer adminId){
        return adminPosAdService.PosAdUploader(adminPosAdDTO,adminId);
    }

    @ApiOperation("POS广告反显 -「详情信息」")
    @LogAnno
    @GetMapping(value = {"posAdDetails/{posAdId}}"})
    public Response PosAdDetails(@PathVariable("posAdId") Long posAdId){
        return adminPosAdService.PosAdDetails(posAdId);
    }

    @ApiOperation("POS广告编辑 - 「更新｜删除」")
    @LogAnno
    @PostMapping(value = {"posAdUpdate"})
    public Response PosAdUpdate(@RequestBody AdminPosAdDTO adminPosAdDTO){
        return adminPosAdService.PosAdUpdate(adminPosAdDTO);
    }

    @ApiOperation("POS广告删除 - 「批量｜删除」")
    @LogAnno
    @PatchMapping(value = {"posAdDeleted"})
    public Response PosAdDeleted(@RequestBody Long[] posAds){
        return adminPosAdService.PosAdDeleted(posAds);
    }

    @ApiOperation("POS广告列表 -「搜索｜分类」")
    @LogAnno
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page",value = "当前页"),
            @ApiImplicitParam(name = "limit",value = "当前数量"),
            @ApiImplicitParam(name = "shopId",value = "门店ID"),
            @ApiImplicitParam(name = "adminId",value = "上传人员")
    })
    @GetMapping(value = {"posAdSearchAll"})
    public Response PosAdSearchAll(@RequestParam(value = "page",defaultValue = "1") Integer page,
                                   @RequestParam(value = "limit",defaultValue = "20") Integer limit,
                                   Integer shopId,Integer adminId){
        return adminPosAdService.PosAdSearchAll(page,limit,shopId,adminId);
    }

    @ApiOperation("POS管理用户 - 「列表｜选择」")
    @LogAnno
    @PatchMapping(value = {"posAdAdminUserS"})
    public Response posAdAdminUserS(){
        return adminPosAdService.posAdAdminUserS();
    }

    @ApiOperation("POS指定门店 - 「列表｜查看」")
    @LogAnno
    @PostMapping(value = {"posAdShopS"})
    public Response posAdShopS(@RequestBody List<Integer> shopIds){
        return adminPosAdService.posAdShopS(shopIds);
    }

    @ApiOperation("上传文件 - 「MP4｜JPG｜PNG｜GIF」")
    @LogAnno
    @PostMapping(value = {"posAdvanced"})
    public Response posAdvanced(@RequestParam("file") MultipartFile file){
            return adminPosAdService.posAdvanced(file);
    }

    @ApiOperation("Minio上传文件 - 「MP4｜JPG｜PNG｜GIF」")
    @LogAnno
    @PostMapping(value = {"posAdMiniio"})
    public Response posAdMiniio(@RequestParam("file") MultipartFile file){
        return adminPosAdService.posAdMiniio(file);
    }

    @ApiOperation("POS广告查看-「广告｜查看」")
    @LogAnno
    @PostMapping(value = {"posAdImgObjS"})
    public Response posAdImgObjS(@RequestBody List<Integer> adImgObjS){
        return adminPosAdService.posAdImgObjS(adImgObjS);
    }

    @ApiOperation("POS广告管理员-「管理员｜选择」")
    @LogAnno
    @GetMapping(value = {"posAdAdminS"})
    public Response posAdAdminS(@LoginAdminId Integer adminId){
        return adminPosAdService.posAdAdminS(adminId);
    }

    @ApiOperation("POS门店-「选择｜列表」")
    @LogAnno
    @GetMapping(value = {"posAdShopOptionS"})
    public Response posAdShopOptionS(@LoginAdminId Integer adminId){
        return adminPosAdService.posAdShopOptionS(adminId);
    }


}
